<?php
namespace Helper\Action\Intelihelp;

class Tarefa
{
	public function numero(\Entities\Intelihelp\Tarefa $tarefa)
	{
		$dstarefa	= htmlentities($tarefa->getDsTarefa());
		$return = "<a class='overlay label label-info' data-html='true' data-trigger='hover' data-title='{$tarefa->getDsTitulo()}' data-content=\"{$dstarefa}\" href='".BASE_PATH."intelihelp/tarefa/viewAnotacao/id/{$tarefa->getIdTarefa()}'>";
		$return.= $tarefa->getIdTarefa();
		$return.= "</a>";
		return $return;
	}
	public function atualizar(\Entities\Intelihelp\Tarefa $tarefa)
	{
		if ($tarefa->getStatus()->getFlSituacao() == 1)
		{
			$return = "<a class='ico-upgrade overTitle' title='Atualizar' href='".BASE_PATH."intelihelp/tarefa/viewCadastrar/id/{$tarefa->getIdTarefa()}' data-target='#myModal' data-toggle='modal'>";
			$return.= "</a>";
			return $return;
		}
	}

	public function interacao(\Entities\Intelihelp\Tarefa $tarefa)
	{
		if ($tarefa->getStatus()->getFlSituacao() == 1)
		{
			$return = "<a class='ico-plus overTitle' title='Interagir' href='".BASE_PATH."intelihelp/tarefa/viewAdicionarAnotacao/id/{$tarefa->getIdTarefa()}' data-target='#myModal' data-toggle='modal'>";
			$return.= "</a>";
			return $return;
		}
	}

	public function atribuir(\Entities\Intelihelp\Tarefa $tarefa)
	{
		if ($tarefa->getStatus()->getFlSituacao() == 1)
		{
			$return = "<a class='ico-users overTitle' title='Atribuir' href='".BASE_PATH."intelihelp/tarefa/viewAtribuir/id/{$tarefa->getIdTarefa()}' data-target='#myModal' data-toggle='modal'>";
			$return.= "</a>";
			return $return;
		}
	}

	public function fechar(\Entities\Intelihelp\Tarefa $tarefa)
	{
		if ($tarefa->getStatus()->getFlSituacao() == 1)
		{
			$return = "<a class='ico-link-out overTitle' title='Finalizar' href='".BASE_PATH."intelihelp/tarefa/viewFechar/id/{$tarefa->getIdTarefa()}' data-target='#myModal' data-toggle='modal'>";
			$return.= "</a>";
			return $return;
		}
	}

	public function reabrir(\Entities\Intelihelp\Tarefa $tarefa)
	{
		$usuario	= unserialize($_SESSION[SESSION_LOGIN]['usuario']);

		if ($tarefa->getStatus()->getFlSituacao() == 0 && $tarefa->getSolicitante()->getIdPessoa() == $usuario->getIdPessoa())
		{
			$return = "<a class='ico-forward overTitle' title='Reabrir' href='".BASE_PATH."intelihelp/tarefa/viewReabrir/id/{$tarefa->getIdTarefa()}' data-target='#myModal' data-toggle='modal'>";
			$return.= "</a>";
		}
		else
		{
			$return = null;
		}
		return $return;
	}

	public function avaliar(\Entities\Intelihelp\Tarefa $tarefa)
	{
		$usuario	= unserialize($_SESSION[SESSION_LOGIN]['usuario']);

		if ($tarefa->getStatus()->getFlSituacao() == 0 && $tarefa->getSolicitante()->getIdPessoa() == $usuario->getIdPessoa())
		{
			$return = "<a class='ico-star overTitle' title='Avaliar' href='".BASE_PATH."intelihelp/tarefa/viewAvaliar/id/{$tarefa->getIdTarefa()}'>";
			$return.= "</a>";
		}
		else
		{
			$return = null;
		}
		return $return;
	}

	public function getPrazo(\Entities\Intelihelp\Tarefa $tarefa)
	{
		$retorno = null;
		if ($tarefa->getDtPrazo() != null)
		{
			$class		= null;
			if ($tarefa->getStatus()->getFlSituacao() == 1)
			{
				$dataAtual	= new \DateTime(date('Y-m-d'));
				$class 		= 'label-info';

				if ($tarefa->getDtPrazo() == $dataAtual)
					$class = 'label-warning';
				else if ($tarefa->getDtPrazo() < $dataAtual)
					$class = 'label-important';
			}

    		$retorno.= "<span class='label {$class}'>";
			$retorno.= $tarefa->getDtPrazo()->format('d/m/Y');
    		$retorno.= "</span>";
		}
		return $retorno;
	}
}